  {  Petrova Tatjana
     2012/11/19
     This program gives you sum of  natural numbers.}
program SumOfNaturalNumbers;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Summer=class
     N:integer;
     procedure Sum;virtual;abstract;
  end;
  SummerFast=class(Summer)
     procedure Sum;  override;
  end;
  SummerSlow=class(Summer)
     procedure Sum; override;
  end;
procedure SummerFast.Sum;
var
  sum:real;
begin
  sum :=(N*(N+1))/2;
  writeln(sum:0:5);
end;
procedure SummerSlow.Sum;
var
  sum,i : integer;
begin
  sum :=0;
  for i:=1 to N do
  begin
    sum:=sum+i;
  end;
  writeln(sum);
end;
var
  s:SummerSlow;
  s1:SummerFast;

begin
  s:=SummerSlow.Create;
  readln(s.N);
  s.Sum;
  s1:=SummerFast.Create;
  s1.N:=s.N;
  s1.Sum;
  readln;
end.


